<%@ page import="com.dbpms.until.Constants" %><%--
  Created by IntelliJ IDEA.
  User: 20275
  Date: 2023/11/18
  Time: 16:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@include file="/pages/common/head.jsp"%>

<div id="page-wrapper">
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">查看寝室信息</h1>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    寝室信息管理 >> 查看寝室信息
                </div>
                <div class="panel-body">

                    <div style=" overflow-x: auto;white-space: nowrap;">
                        <div class="row">
                            <div class="col-lg-4">
                                <div class="form-group">
                                    <label>寝室楼</label>
                                    <select class="form-control"  id="ChamberFloor_name_select" name="ChamberFloor_name_select">
                                        <option value="0">------</option>
                                        <c:forEach items="${chamberfloorinfos}" var="info">
                                            <c:if test="${Chamber_floor_name_select != null}">

                                                <c:if test="${Chamber_floor_name_select == info.chamberFloorId}">
                                                    <option value="${info.chamberFloorId}" selected>${info.chamberFloorName}</option>
                                                </c:if>
                                                <c:if test="${Chamber_floor_name_select != info.chamberFloorId}">
                                                    <option value="${info.chamberFloorId}">${info.chamberFloorName}</option>
                                                </c:if>

                                            </c:if>
                                            <c:if test="${Chamber_floor_name_select == null}">

                                                <option value="${info.chamberFloorName}">${info.chamberFloorName}</option>

                                            </c:if>
                                        </c:forEach>
                                    </select>
                                </div>
                            </div>
                            <div class="col-lg-4">
                                <div class="form-group">
                                    <label>楼层</label>
                                    <select class="form-control" id="ChamberFloor_f_select" name="ChamberFloor_f_select">
                                        <option value="0">------</option>
                                        <c:forEach begin="1" end="6" var="i">
                                            <c:if test="${Chamber_floor_number_select != null}">
                                                <c:if test="${Chamber_floor_number_select == i}">
                                                    <option value="${i}" selected>${i}层</option>
                                                </c:if>
                                                <c:if test="${Chamber_floor_number_select != i}">
                                                    <option value="${i}">${i}层</option>
                                                </c:if>
                                            </c:if>
                                            <c:if test="${Chamber_floor_number_select == null}">
                                                <option value="${i}">${i}层</option>
                                            </c:if>
                                        </c:forEach>
                                    </select>

                                </div>

                            </div>
                            <div class="col-lg-4">
                                <label style="visibility: hidden;">&nbsp;</label>
                                <div class="input-group">
                                    <span class="input-group-btn">
                                        <button class="btn btn-default" id="find_Chamber_button" type="button">查找</button>
                                        <button class="btn btn-default" id="find_All_Chamber_button" type="button">查找全部信息</button>
                                    </span>
                                </div>
                            </div>

                        </div>
                        <br />
                        <table width="100%" class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr>
                                <th>#</th>
                                <th>寝室楼</th>
                                <th>楼层</th>
                                <th>寝室号</th>
                                <th>寝室类型</th>
                                <th>寝室最大人数</th>
                                <th>现住人数</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                                <c:forEach varStatus="i" items="${chamberInfo}" var="Info">
                                    <tr>
                                        <td>${i.index + 1}</td>
                                        <td style="display: none;">${Info.chamberId}</td>
                                        <td>${Info.chamberFloorName}</td>
                                        <td>${Info.chamberFloor}层</td>
                                        <td>${Info.chamberHotelNumber}</td>
                                        <td>${Info.chamberTypeName}</td>
                                        <td>${Info.chamberBed}人</td>
                                        <td>${Info.chamberNumberOfPeople}人</td>
                                        <td>
                                            <p>
                                                <a class="btn btn-info" href="${pageContext.request.contextPath }/chamber/toShowChamberStuInfo?chamber_id=${Info.chamberId}">查看寝室学生</a>
                                                <a class="btn btn-primary"
                                                   href="${pageContext.request.contextPath }/chamber/toUpdateInfo?chamber_id=${Info.chamberId}">修改</a>
                                                <a class="btn btn-danger delete_button"
                                                   href="${pageContext.request.contextPath }/chamber/delete?chamber_id=${Info.chamberId}">删除</a>
                                            </p>
                                        </td>
                                    </tr>
                                </c:forEach>
                            </tbody>
                        </table>
                    </div>
                    <div>
                        <div style="float: left;">显示第${(page_no-1)*page_size+1}到第${((page_no-1)*page_size+1)+query_items-1}条记录
                            ，总共${total}条记录，每页显示
                            <a id="hidden_a" style="display: none"></a>
                            <select id="pages_num" name="pages_num">
                                <c:forEach var="i" begin="1" end="5">
                                    <c:if test="${page_size == (i*5)}">
                                        <option value="${i*5}" selected="selected">${i*5}</option>
                                    </c:if>
                                    <c:if test="${page_size != (i*5)}">
                                        <option value="${i*5}">${i*5}</option>
                                    </c:if>
                                </c:forEach>
                            </select>
                            条记录
                        </div>
                        <div style="float: right;">
                            <nav aria-label="Page navigation example">
                                <ul class="pagination">
                                    <li class="page-item">
                                        <a href="${pageContext.request.contextPath }/chamber/toShowInfo?page_no=1" aria-hidden="true">&laquo;</a>
                                    </li>
                                    <c:forEach var="i" begin="1" end="${pages}">
                                        <c:if test="${page_no == i}">
                                            <li class="active">
                                                <a href="${pageContext.request.contextPath }/chamber/toShowInfo?page_no=${i}&page_size=${page_size}&Chamber_floor_name_select=${Chamber_floor_name_select}&Chamber_floor_number_select=${Chamber_floor_number_select}">${i}</a>
                                            </li>
                                        </c:if>
                                        <c:if test="${page_no != i}">
                                            <li class="page-item">
                                                <a href="${pageContext.request.contextPath }/chamber/toShowInfo?page_no=${i}&page_size=${page_size}&Chamber_floor_name_select=${Chamber_floor_name_select}&Chamber_floor_number_select=${Chamber_floor_number_select}">${i}</a>
                                            </li>
                                        </c:if>
                                    </c:forEach>
                                    <li class="page-item">
                                        <a href="${pageContext.request.contextPath }/chamber/toShowInfo?page_no=${pages}" aria-hidden="true">&raquo;</a>
                                    </li>
                                </ul>
                            </nav>
                        </div>
                        <div style="content:'';clear:both;display:table;"></div>

                    </div>
                </div>
            </div>
        </div>

    </div>

</div>


<c:if test="${message != null}">
    <script>
        alert("${message}")
        location.href = "${pageContext.request.contextPath}"+"/chamber/toShowInfo"
    </script>
    <% session.removeAttribute(Constants.MESSAGE); %>
</c:if>

<script>
    $(document).ready(function() {
        // 页面数量发生改变方法
        $('#pages_num').change(function() {
            var pages_num = $(this).val();
            var chamber_name= $("#ChamberFloor_name_select").val()
            var chamber_value= $("#ChamberFloor_f_select").val()

            // console.log("选择页面数量为："+pages_num)
            location.href = "${pageContext.request.contextPath}"+
                "/chamber/toShowInfo?page_size="+pages_num+"&Chamber_floor_name_select="+chamber_name+"&Chamber_floor_number_select="+chamber_value
        });
        // 查找全部寝室信息按钮
        $("#find_All_Chamber_button").click(function(){
            location.href = "${pageContext.request.contextPath}"+"/chamber/toShowInfo"
        });
        // 查找寝室按钮
        $("#find_Chamber_button").click(function(){
            var ChamberFloor_name_select = $('#ChamberFloor_name_select').val();
            var ChamberFloor_f_select = $('#ChamberFloor_f_select').val();
            console.log("ChamberFloor_name_select："+ChamberFloor_name_select);
            console.log("ChamberFloor_f_select："+ChamberFloor_f_select);

            if(ChamberFloor_name_select != 0 || ChamberFloor_f_select != 0){
                location.href = "${pageContext.request.contextPath}"+"/chamber/toShowInfo" +
                    "?Chamber_floor_name_select="+ChamberFloor_name_select+"&Chamber_floor_number_select="+ChamberFloor_f_select
            }
        });

    });
</script>

<%@include file="/pages/common/foot.jsp" %>
